package org.example.order.common;

import lombok.Data;
import org.example.order.exception.IllegalGoodFilterException;

@Data
public class GoodFilter {
    private String name = null;
    private String classification = null;
    private String status = null;
    private Double priceStart = null;
    private Double priceEnd = null;
    private int pageNum = 1;
    private int pageSize = 10;

    public void checkFilter() throws IllegalGoodFilterException {
        if (priceStart != null && priceEnd != null && priceStart > priceEnd) {
            throw new IllegalGoodFilterException("起始价格不能大于结束价格");
        }
        if (pageNum < 1) {
            throw new IllegalGoodFilterException("商品偏移量不能小于0");
        }
        if (pageSize < 0) {
            throw new IllegalGoodFilterException("商品展示数量不能小于0");
        }
    }
}
